﻿using MES.Desktop.Common;
using MES.Desktop.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MES.Desktop.SystemModule.Models
{
    public class FuncModel : DataModelBase
    {
        public FuncModel() { }

        IFuncService _funcService;
        public FuncModel(IFuncService funcService)
        {
            _funcService = funcService;
        }
        private bool _isSelected;

        public bool IsSelected
        {
            get { return _isSelected; }
            set { SetProperty<bool>(ref _isSelected, value); }
        }

        public int Index { get; set; }

        public int FuncId { get; set; }

        private string _funcName;

        public string FuncName
        {
            get { return _funcName; }
            set
            {
                SetProperty<string>(ref _funcName, value);

                this.ClearErrors();
                if (string.IsNullOrEmpty(_funcName))
                {
                    this.RaiseErrors("功能名不能为空");
                }
                if (_funcService != null && _funcService.CheckName(value, FuncId))
                {
                    this.RaiseErrors("功能名不能重复");
                }
            }
        }


    }
}
